import { STORAGE_KEYS } from './defines';

interface AuthInfo {
  authorization: string;
  ptoken: string;
}

/**
 * 获取认证信息
 * @returns 认证信息对象
 */
export async function getAuthInfo(): Promise<AuthInfo | null> {
  try {
    const authInfo = await chrome.storage.local.get([
      STORAGE_KEYS.AUTH,
      STORAGE_KEYS.PTOKEN
    ]);

    if (!authInfo[STORAGE_KEYS.AUTH] || !authInfo[STORAGE_KEYS.PTOKEN]) {
      return null;
    }

    return {
      authorization: authInfo[STORAGE_KEYS.AUTH],
      ptoken: authInfo[STORAGE_KEYS.PTOKEN]
    };
  } catch (error) {
    console.error('获取认证信息失败:', error);
    return null;
  }
} 